/*
Copyright (c) 2008,2009, David Beck

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef _rt0d4_rx_secobj_priv_hh_included_
#define _rt0d4_rx_secobj_priv_hh_included_

/**
   @file secobj_priv.hh
   @brief secobj_priv contains the Rx security model related data

   This is an internal class that is based on rt0d4::sec classes
*/

#include "common.h"
#include "validate_cb.h"
#include "conn_cb.h"
#ifdef __cplusplus
#include <memory>
#include <string>

namespace rt0d4
{
  namespace rx
  {
    /** @brief Internal class that stores the Rx security model related data */
    class secobj_priv
    {
    public:
      /* manage algorithms */
      bool add_algoritms(const char ** algs);
      const char ** get_algorithms() const;

      /* manage key strengths */
      bool set_eckey_strength(int min, int max);
      void get_eckey_strength(int & min, int & max) const;
      int get_eckey_strength_min() const;
      int get_eckey_strength_max() const;

      /* packet encryption */
      void encrypt_packets(bool yesno);
      bool encrypt_packets() const;

      /* validation */
      void set_peer_cert_validation_cb( validate_peer_cert cert_validate_cb );
      void set_peer_credentials_validation_cb( validate_peer_credentials creds_validate_cb );
      validate_peer_cert get_peer_cert_validation_cb() const;
      validate_peer_credentials get_peer_credentials_validation_cb() const;
      
      /* connection related callbacks */
      void set_destroy_conn_data_cb( destroy_conn_data destroy_conn_data_cb );
      void set_create_conn_data_cb( create_conn_data create_conn_data_cb );
      destroy_conn_data get_destroy_conn_data_cb() const;
      create_conn_data get_create_conn_data_cb() const;

      /* own cert */
      void set_own_cert(const unsigned char * p, size_t len);
      const unsigned char * get_own_cert(size_t & len) const;

      /* own creds */
      void set_own_credentials(const char * login, const char * pass);
      const char * get_own_login() const;
      const char * get_own_pass() const;

      /* client?/server? */
      bool is_server();

      /* debug */
      void set_debug(size_t debug_lifetime);
      bool do_debug();

      secobj_priv(bool is_server);
      ~secobj_priv();

      struct impl;
    private:
      /* private data */
      std::auto_ptr<impl> impl_;

      /* copying not allowed */
      secobj_priv(const secobj_priv & other);
      secobj_priv & operator=(const secobj_priv & other);

      /* default construction not allowed */
      secobj_priv();
    };
  }
}

#endif /* __cplusplus */
#endif /* _rt0d4_rx_secobj_priv_hh_included_ */
